import { ModalController } from '@ionic/angular';
import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-password-modal',
  templateUrl: './password-modal.component.html',
  styleUrls: ['./password-modal.component.scss'],
})
export class PasswordModalComponent implements OnInit {
  item: any = {value: ''};
  constructor(
    public modalController: ModalController,
  ) { }

  ngOnInit() {
  }
  onCancelClick(e) {
    e.stopPropagation();
  }
  dismissClick() {
    // this.modalController.dismiss({ data: link });

    this.modalController.dismiss();
  }

  passWordIonBlur(item) {
    item.onFocus = false;
  }
  passWordIonFocus(item) {
    item.onFocus = true;
  }

  changeValue(event, item) {

    if (event.detail.value.length > 6) {
      item.value = event.detail.value.slice(0, 6);
    } else {
      // item.value = event.detail.value;
    }
    if (item.value.length  === 6) {
      this.modalController.dismiss({ data: item.value });

    }
  }
}
